package com.fr.report.script.core.parser;

import com.fr.report.script.Calculator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ConditionalOrExpression extends BinaryExpression
{
  private static final String OR = "||";
  ConditionalAndExpression[] ands;

  ConditionalOrExpression(ConditionalAndExpression[] paramArrayOfConditionalAndExpression)
  {
    this.ands = paramArrayOfConditionalAndExpression;
  }

  public Object eval(Calculator paramCalculator)
    throws UtilEvalError
  {
    if (this.ands.length == 0)
      throw new InterpreterError("conditionalAndList should not be empty");
    Object localObject1 = null;
    for (int i = 0; i < this.ands.length; ++i)
    {
      if (i == 0)
      {
        localObject1 = this.ands[i].eval(paramCalculator);
      }
      else
      {
        Object localObject2 = this.ands[i].eval(paramCalculator);
        localObject1 = binaryOperation(localObject1, localObject2, "||");
      }
      if ((i == this.ands.length - 1) || (!(OperationUtils.isFalse(localObject1))))
        return localObject1;
    }
    return localObject1;
  }

  protected Object objectBinaryOperation(Object paramObject1, Object paramObject2, String paramString)
  {
    return ((OperationUtils.isFalse(paramObject1)) ? paramObject2 : paramObject1);
  }

  public void traversal4Tiny(TinyHunter paramTinyHunter)
  {
    for (int i = 0; i < this.ands.length; ++i)
      this.ands[i].traversal4Tiny(paramTinyHunter);
  }

  public String exString(Calculator paramCalculator)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < this.ands.length; ++i)
    {
      if (i > 0)
        localStringBuffer.append(" || ");
      localStringBuffer.append(this.ands[i].exString(paramCalculator));
    }
    return localStringBuffer.toString();
  }

  public String toString()
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < this.ands.length; ++i)
    {
      if (i > 0)
        localStringBuffer.append(" || ");
      localStringBuffer.append(this.ands[i].toString());
    }
    return localStringBuffer.toString();
  }

  public String getExpression(int paramInt1, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < this.ands.length; ++i)
    {
      if (i > 0)
        localStringBuffer.append(" || ");
      localStringBuffer.append(this.ands[i].getExpression(paramInt1, paramInt2, paramInt3, paramInt4, paramBoolean));
    }
    return localStringBuffer.toString();
  }

  public String[] parserParameter()
  {
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    int j = this.ands.length;
    while (i < j)
    {
      localArrayList.addAll(Arrays.asList(this.ands[i].parserParameter()));
      ++i;
    }
    return ((String[])localArrayList.toArray(new String[localArrayList.size()]));
  }
}